fix a few -Wstringop-truncation warnings (#565)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sat, 23 May 2020 21:36:29 +0000 (15:36 -0600)
committerGitHub <noreply@github.com>
Sat, 23 May 2020 21:36:29 +0000 (15:36 -0600)
commit4231b0304d47ef7810f8615e64fda2da093bec4a
tree54697a6e6300431ed00bf3224f17364180130f97
parent9564cd5d6c87218989482846cd877f946468c123
fix a few -Wstringop-truncation warnings (#565)

* fix -Wstringop-truncation warning in bushnell.

* fix -Wstringop-truncation in alantrl.

* fix -Wstringop-truncation warning in garmin, and a real error.

The real error:
In garmin.cc route_hdr_pr would fail to terminate the
GPS_SWay rte_ident member if latin1 encoded route name was longer
than 255 characters.  Subsequently garmin.cc route_write passes the
GPS_SWay structure to GPS_Command_Send_Route.  GPS_Command_Send_Route
may call GPS_A20[01]_Send which may call GPS_D202_Send.  GPS_D202_Send
assumes that rte_ident is null terminated.

The other change only silences the warning, the character array was
subsequently terminated anyway.

* fix -Wstringop-truncation warning in enigma.

These are nonstrings.  They are not required to be null terminated.

A real reference file caputred from MGL Central 2.0 is added.  In it
you can see that don't care values are not all filled with a particular
value.  We fill them with NULLs are a result of zeroing the structure before
we write it.  You can also see the 1000m offset in altitudes is correct.

* correct reference file mode.

* fix two strncpy warnings that gcc 9.3.0 doesn't issue.

Perhaps it is a gcc bug that these didn't cause warnings.  It seems
to be related to the fact they were the last member in the structure.
In any event, we can copy 1 byte less, we explicitly add a terminator
subsequently.
alan.cc
bushnell.cc
enigma.cc
garmin.cc
reference/mglcentral20.ert [new file with mode: 0644]
reference/mglcentral20.gpx [new file with mode: 0644]
testo.d/enigma.test